<?php


namespace App\Services;


use App\Models\CarBrandStat;
use App\Models\DealerStat;
use App\Models\RollStat;
use App\Models\WarrantyStat;

class StatCompareService
{
    private $dealerStatModel;

    private $carBrandStatModel;

    protected $warrantyStatModel;

    private $rollStatModel;

    public function __construct(DealerStat $dealerStat, CarBrandStat $carBrandStat, WarrantyStat $warrantyStat, RollStat $rollStat)
    {
        $this->warrantyStatModel = $warrantyStat;
        $this->dealerStatModel = $dealerStat;
        $this->carBrandStatModel = $carBrandStat;
        $this->rollStatModel = $rollStat;
    }

    public function allSales(int $type)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');
        return $this->dealerStatModel->getAllSales($start_date, $end_date, $type);
    }

    public function allScores(int $type)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');
        return $this->dealerStatModel->getAllScores($start_date, $end_date, $type);
    }

    public function distSales(int $type)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');
        return $this->dealerStatModel->getDistSales($start_date, $end_date, $type);
    }

    public function distScores(int $type)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');
        return $this->dealerStatModel->getDistScores($start_date, $end_date, $type);
    }

    public function dealerSales(int $type)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');
        return $this->dealerStatModel->getDealerSales($start_date, $end_date, $type);
    }

    public function dealerScores(int $type)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');
        return $this->dealerStatModel->getDealerScores($start_date, $end_date, $type);
    }

    public function brandTotal()
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');

        return $this->carBrandStatModel->brandTotal($start_date, $end_date);
    }

    public function mostBrand()
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');

        return $this->carBrandStatModel->mostBrand($start_date, $end_date);
    }

    public function mostModel()
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');

        return $this->carBrandStatModel->mostModel($start_date, $end_date);
    }

    public function warrantyTotal()
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d', strtotime('+1 day'));

        return $this->warrantyStatModel->warrantyTotal($start_date, $end_date);
    }

    public function warrantyNum($type)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');

        return $this->warrantyStatModel->warrantyNum($start_date, $end_date, $type);
    }

    public function warrantyRoll(int $film_type_id)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');

        return $this->warrantyStatModel->warrantyRoll($start_date, $end_date, $film_type_id);
    }

    public function sales(int $type, int $user_type)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');

        return $this->rollStatModel->sales($type, $user_type, $start_date, $end_date);
    }

    public function transfer(int $type, int $user_type)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');

        return $this->rollStatModel->transfer($type, $user_type, $start_date, $end_date);
    }

    public function return(int $type, int $user_type)
    {
        $start_date = date('Y') . '-01';
        $end_date = date('Y-m-d');

        return $this->rollStatModel->return($type, $user_type, $start_date, $end_date);
    }
}